package guda.house.biz.form.village;

import guda.house.biz.util.FloatUtil;
import guda.house.dal.dataobject.SuiteDO;

import javax.validation.constraints.NotNull;
import java.text.SimpleDateFormat;

/**
 * Created by well on 15/11/13.
 */
public class SuiteEditForm extends SuiteForm{

    @NotNull(message = "不能为空")
    private Long suiteId;

    public void initForm(SuiteDO suiteDO){
        setSuiteName(suiteDO.getSuiteName());
        setSuiteId(suiteDO.getSuiteId());
        setUseType(suiteDO.getUseType());
        setTypeWater(suiteDO.getTypeWater());
        setSuiteComment(suiteDO.getSuiteComment());
        setCardElectrical(suiteDO.getCardElectrical());
        setCardOwner(suiteDO.getCardOwner());
        setCardWater(suiteDO.getCardWater());
        setEmployeeId(suiteDO.getEmployeeId());
        setOfficeVarId(suiteDO.getOfficeVarId());
        setBuildingTypeId(suiteDO.getBuildingTypeId());
        if(suiteDO.getGmtCheckin()!=null) {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
            setGmtCheckin(simpleDateFormat.format(suiteDO.getGmtCheckin()));
        }
        if(suiteDO.getGmtDelivery()!=null) {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
            setGmtDelivery(simpleDateFormat.format(suiteDO.getGmtDelivery()));
        }
        setIsCheckin(suiteDO.getIsCheckin());
        setIsDecoration(suiteDO.getIsDecoration());
        if(suiteDO.getSuiteArea()!= null){
            setSuiteArea(FloatUtil.format2kilogram(suiteDO.getSuiteArea()));
        }
        setTypeElectrical(suiteDO.getTypeElectrical());


    }

    public SuiteDO toDO(){
        SuiteDO suiteDO =super.toDO();
        suiteDO.setSuiteId(suiteId);
        return suiteDO;
    }

    public Long getSuiteId() {
        return suiteId;
    }

    public void setSuiteId(Long suiteId) {
        this.suiteId = suiteId;
    }
}
